Node-RED block in Snap4City Microservice library node-red-contrib-snap4city-developer is "service-search-near-service">

It allows to retrieve the set of services that are near a given service identified by its serviceUri. The services can be filtered as belonging to specific categories (e.g. Accomodation, Hotel, Restaurant etc), model or value.

Inputs

A JSON with these parameters:
typeQuery string
If "point-of-interest" is selected, the system will perform a search of the data contained in the Knowledge Base (KB) if, on the other hand, the user selects "entity," the system will perform a search using iot-search.
serviceuri string
serviceUri (http://...) of the service (info about ServiceUri)
filter string
Only for the type "entity", a list of conditions (separated with ;) on value names matching a constant value. The matching operator can be: If multiple conditions are present they are considered in AND.
values string
Only for the type "entity". If filter is not empty, list of value names (separated by ;) to be returned for each result, if omitted all values are returned.
sortOnValue string
Only for the type "entity". If filter is not empty, the value name to sort the result, it can be like "value name:asc|desc:type" (e.g. temperature:desc:short), order direction is "asc" if omitted, type can be string, date, long or short (if type is omitted string is assumed). The type is used to force sorting for dates and numbers. If the parameter is omitted the sort is on the distance from GPS position, if "none" is specified no specific sort is used.
categories string
the list of categories of the services to be retrieved separated with semicolon, if omitted all kinds of services are returned. It can contain macro categories or categories, if a macro category is specified all categories in the macro category are used. The complete list of categories and macro categories can be retrieved on servicemap.disit.org
model string
search for iot devices created with a specific model name.
maxdistance number
maximum distance from the GPS position of the services to be retrieved, expressed in Km (0.1 is used if parameter is missing) if it is equal to “inside” it searches for services with a WKT geometry that contains the specified GPS position (e.g a park)
maxresults number
maximum number of results to be returned (if parameter is missing 100 is assumed), if it is 0 all results are returned
lang string
ISO 2 chars language code (e.g. “it”, “en”, “fr”, “de”, “es”) to be used for returned descriptions if available in multiple languages. Currently for languages other than “it” and “en” it returns “en” descriptions. (if parameter is missing “en” is assumed)
geometry boolean
true/false, if true it returns a “hasGeometry” property for each service stating if the service has a complex WKT geometries (linestring, polygon) associated with it (if parameter is missing “false” is assumed)

Outputs

  1. ServiceUri Array
    Returns an array containing the servicesUri of each service found
  2. GeoJSON Results
    It returns the services split in three sections (BusStops , SensorSites, Services). Each section is provided as GeoJSON “FeatureCollection”, the results are sorted by distance, additionally in each section the “fullCount” property reports the full number of results available matching the query
  3. All services together
    It returns the services merge in Results section

Details

The node can receive a JSON with the parameters described in the Inputs section and with them generate the output JSON. If the values are not present in the input JSON, these are read by those in the configuration. If they are not present in either part, an error is generated for the necessary parameters.